package org.walkerljl.boss.dao.auth.res.impl;

import org.springframework.stereotype.Repository;
import org.walkerljl.boss.dao.auth.res.MenuDao;
import org.walkerljl.boss.support.dao.impl.BaseDaoImpl;
import org.walkerljl.boss.domain.auth.res.Menu;
import org.walkerljl.commons.data.model.tree.TreeNode;
import org.walkerljl.commons.util.MapUtils;

import java.util.List;
import java.util.Map;

/**
 * MenuDao
 *
 * @author lijunlin
 */
@Repository("menuDao")
public class MenuDaoImpl extends BaseDaoImpl<Long, Menu> implements MenuDao {

    public MenuDaoImpl() {
        super.baseNameSpace = "org.walkerljl.identity.dao.auth.res.MenuDao";
    }

    @Override
    public List<TreeNode> selectChildNodesByAppIdAndParentId(Long appId, Long parentId) {
        if (appId == null || parentId == null) {
            return null;
        }
        Map<String, Object> params = MapUtils.newHashMap();
        params.put("appId", appId);
        params.put("parentId", parentId);
        return selectList(getNameSpace("selectChildNodesByAppIdAndParentId"), params);
    }
}